package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.domain.Record;
import cn.wolfcode.trip.base.service.IRecordService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

//余额的记录
@RestController
@RequestMapping("/record")
public class RecordController {
    @Autowired
    private IRecordService recordService;

    /**
     * 查询提现界面的数据
     *
     * @return
     */
    @GetMapping
    public List<Record> listAll() {
        List<Record> records = recordService.listAll(Record.STATE_DEPOSIT);
        return records;
    }

    /**
     * 提现记录
     *
     * @param
     * @return
     */
    @GetMapping("/deposit")
    public JSONResult listDeposit(Long id) {
        JSONResult json = new JSONResult();
        //设置状态为提现
        List<Record> list = recordService.listDeposit(id, Record.STATE_DEPOSIT);
        json.setResult(list);
        return json;
    }

    /**
     * 充值记录
     *
     * @param
     * @return
     */
    @GetMapping("/recharge")
    public List<Record> listRecharge(Long id) {
        //设置状态为提现
        List<Record> list = recordService.listRecharge(id, Record.STATE_TOPUP);
        return list;
    }
}
